#include "GameObject.h"

GameObject::GameObject()
    : m_position(0.0f, 0.0f, 0.0f)
    , m_rotation(0.0f, 0.0f, 0.0f)
    , m_scale(1.0f, 1.0f, 1.0f)
{
}

GameObject::~GameObject()
{
}

void GameObject::SetPosition(const D3DXVECTOR3& pos)
{
    m_position = pos;
    // Note: Bounding box is kept in local space (relative to object center)
    // Collision detection will transform it to world space when needed
}

void GameObject::SetRotation(const D3DXVECTOR3& rot)
{
    m_rotation = rot;
}

void GameObject::SetScale(const D3DXVECTOR3& scale)
{
    m_scale = scale;
}

bool GameObject::CheckCollision(const GameObject& other) const
{
    // Transform local bounding boxes to world space
    AABB worldBox1;
    worldBox1.minPos = m_boundingBox.minPos + m_position;
    worldBox1.maxPos = m_boundingBox.maxPos + m_position;

    AABB worldBox2;
    worldBox2.minPos = other.GetBoundingBox().minPos + other.GetPosition();
    worldBox2.maxPos = other.GetBoundingBox().maxPos + other.GetPosition();

    return worldBox1.Intersects(worldBox2);
}
